//
//  NSString+EDEncode.m
//  Demo_Encrypt
//
//  Created by ChenBing on 2020/3/9.
//

#import "NSString+EDEncode.h"
#import "NSData+EDEncode.h"
@implementation NSString (EDEncode)

- (NSData *)ed_utf8Data {
    return [self dataUsingEncoding:NSUTF8StringEncoding];
}

- (NSData *)ed_base64DecodeData {
    return [[NSData alloc] initWithBase64EncodedString:self options:NSDataBase64DecodingIgnoreUnknownCharacters];
}

- (NSString *)ed_base64Encode {
    return [self.ed_utf8Data base64EncodedStringWithOptions:0];
}

- (NSString *)ed_base64Decode {
    return self.ed_base64DecodeData.ed_utf8String;
}

- (NSString *)ed_urlEncode {
    return [self stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
}

- (NSString *)ed_urlDecode {
    return [self stringByRemovingPercentEncoding];
}

@end
